<template>
  <el-dialog title="用户编辑" width="500px" v-model="dialogFormVisible">
    <el-form :model="form" size="small">
      <el-form-item label="所属商户" :label-width="formLabelWidth">
        <el-select v-model="form.business_id" placeholder="请选商户">
          <el-option label="华为科技" :value="1"></el-option>
          <el-option label="腾讯科技" :value="2"></el-option>
          <el-option label="小米科技" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="用户名称" :label-width="formLabelWidth">
        <el-input
          v-model="form.username"
          autocomplete="off"
          :disabled="true"
        ></el-input>
      </el-form-item>
      <el-form-item label="密码" :label-width="formLabelWidth">
        <el-input
          type="password"
          v-model="form.password"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="联系方式" :label-width="formLabelWidth">
        <el-input v-model="form.telphone" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="昵称" :label-width="formLabelWidth">
        <el-input v-model="form.nickname" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="角色" :label-width="formLabelWidth">
        <el-select v-model="form.role_id" placeholder="请选角色">
          <el-option label="超级管理员" :value="1"></el-option>
          <el-option label="网关操作员" :value="2"></el-option>
          <el-option label="测试人员" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="描述" :label-width="formLabelWidth">
        <el-input
          type="textarea"
          v-model="form.business_describe"
          autocomplete="off"
        ></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button size="small" @click="cancelFunc()">取 消</el-button>
        <el-button size="small" type="primary" @click="confirmFunc()"
          >确 定</el-button
        >
      </span>
    </template>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      //是否显示
      dialogFormVisible: false,
      //表单数据
      form: {
        //用户名称
        username: "",
        //联系方式
        telphone: "",
        //所属平台
        business_id: 1,
        //密码
        password: "",
        //昵称
        nickname: "",
        //角色ID
        role_id: 1,
        //描述
        describe: "",
      },
      //左边标签宽度
      formLabelWidth: "120px",
    };
  },
  props: {
    visible: Boolean,
  },
  watch: {
    //监听是否显示
    visible(newVal, oldVal) {
      if (newVal != oldVal) {
        this.dialogFormVisible = newVal;
      }
    },
  },
  created() {},
  methods: {
    /**
     * 确认
     */
    confirmFunc() {
      this.$message({
        type: "success",
        message: "操作成功!",
      });
      this.cancelFunc();
    },

    /**
     * 取消
     */
    cancelFunc() {
      this.$emit("close", false);
    },
  },
};
</script>

<style lang="scss">
</style>